package com.TheEndWork;

import java.util.Scanner;

/**
 * @authoer zsj
 * @date 2022/6/17 21:37
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[][] coins = new int[n][n];
        int[][] dp = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                coins[i][j] = scanner.nextInt();
            }
        }
        dp[0][0] = coins[0][0];
        for (int i = 1; i < n; i++) {
            dp[0][i] = coins[0][i] + dp[0][i - 1];
            dp[i][0] = coins[i][0] + dp[i - 1][0];
        }
        for (int i = 1; i < n; i++) {
            for (int j = 1; j < n; j++) {
                dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]) + coins[i][j];
            }
        }
        System.out.println(dp[n-1][n-1]);
    }
}
